package com.example.emos.api.service.impl;


import com.example.emos.api.common.util.PageUtils;
import com.example.emos.api.db.dao.TbUserDao;
import com.example.emos.api.db.pojo.TbUser;
import com.example.emos.api.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;


@Service
public class UserServiceImpl implements UserService {
    @Autowired
    TbUserDao userDao;

    @Override
    public Integer login(HashMap param) {
        Integer userId = userDao.login(param);
        return userId;
    }

    @Override
    public int updatePassword(HashMap param) {
        int rows = userDao.updatePassword(param);
        return rows;
    }

    @Override
    public PageUtils searchUserByPage(HashMap param) {
        ArrayList<HashMap> list = userDao.searchUserByPage(param);
        long count = userDao.searchUserCount(param);
        int start = (Integer) param.get("start");
        int length = (Integer) param.get("length");
        PageUtils pageUtils = new PageUtils(list, count, start, length);
        return pageUtils;
    }

    @Override
    public int insert(TbUser user) {
        int rows = userDao.insert(user);
        return rows;
    }

    @Override
    public HashMap searchUserSummary(int userId) {
        HashMap map = userDao.searchUserSummary(userId);
        return map;
    }

    @Override
    public TbUser selectUserById(Integer id) {
        TbUser map = userDao.selectUserById(id);
        return map;
    }

    @Override
    public int update(HashMap param) {
        int rows = userDao.update(param);
        return rows;
    }

    @Override
    public int deleteUserByIds(Integer[] ids) {
        int rows = userDao.deleteUserByIds(ids);
        return rows;
    }


    @Override
    public int updateStatusByIds(int id, int status1) {
        int rows = userDao.updateStatusByIds(id, status1);
        return rows;
    }

    @Override
    public HashMap selectUserById1(Integer id) {
        HashMap map = userDao.selectUserById1(id);
        return map;
    }

    @Override
    public int leave(Integer id) {
        int rows = userDao.leave(id);
        return rows;
    }

}

